package com.inspinia.base.web.simple.libs.filter;

import javax.servlet.*;
import java.io.IOException;

/**
 * sitemesh 3.0.1
 * 解决装饰器乱码过滤器
 */
public class EncodingFilter implements Filter{
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
                         FilterChain filterChain) throws IOException, ServletException {
        servletRequest.setCharacterEncoding("utf-8");
        servletResponse.setContentType("text/html;charset=UTF-8");
        filterChain.doFilter(servletRequest, servletResponse);
    }
    @Override
    public void init(FilterConfig arg0) throws ServletException {
        System.setProperty("file.encoding","utf-8");
    }
    @Override
    public void destroy() {
    }
}